package tiny.soft.com.core.config.security.service;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * tiny.soft.com.core.config.security.service
 *
 * @Auther: 宋晓虎
 * @Date: 2019/12/24 23:21
 * @Description:
 */
@Component
public class UserDetailServiceImpl implements UserDetailsService {


    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        List<GrantedAuthority> authorities = new ArrayList<>();
        authorities.add(new SimpleGrantedAuthority("ROLE_admin"));
        User user=new User(s,"$2a$10$pIGEFkmtuy/9tC5zaTxA1.dsXDPf6SP7G4LRaJsDSiiruuo0kuvrG",authorities);
        return new UserDetailImpl(user);
    }
}